home *** CD-ROM | disk | FTP | other *** search
- Path: ccshst05.cs.uoguelph.ca!ccshst01!thay
- From: thay@uoguelph.ca (Toby K Hay)
- Newsgroups: comp.lang.c
- Subject: Re: accessing structures via pointers
- Date: 8 Apr 1996 15:58:22 GMT
- Organization: University of Guelph
- Message-ID: <4kbd2u$rp6@ccshst05.cs.uoguelph.ca>
- References: <1996Apr8.144012.25767@leeds.ac.uk>
- NNTP-Posting-Host: ccshst01.cs.uoguelph.ca
- X-Newsreader: TIN [version 1.2 PL2]
-
- A M Casey (csyamc@scs.leeds.ac.uk) wrote (roughly, with a lot excised):
- : Hi I'm calling the function getgrent(), which returns a pointer to the
- structure:
- : struct group *getgrent(void);
- : and I havent got a clue how to access it.
- : printf("the group name is %s\n",tempgroup.gr_name);
- : doesnt work because tempgroup is a pointer.
-
- To access structure elements through structure pointers you have to use
- "->" instead of ".". That is, "tempgroup->gr_name" instead of
- "tempgroup.gr_name".
- Toby Hay thay@uoguelph.ca
-